/****** Object:  Table [dbo].[Member]    Script Date: 01/20/2012 17:17:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Member](
	[ID] [uniqueidentifier] NOT NULL,
	[Email] [nvarchar](500) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Member] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF)
)
GO
INSERT [dbo].[Member] ([ID], [Email], [Password]) VALUES (N'6005c30a-c5d0-410d-a82c-65431c9638d1', N'shaun.xu@igt.com', N'111')
/****** Object:  Table [dbo].[Application]    Script Date: 01/20/2012 17:17:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Application](
	[ID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](500) NOT NULL,
 CONSTRAINT [PK_Application] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF)
)
GO
INSERT [dbo].[Application] ([ID], [Name]) VALUES (N'00000000-0000-0000-0000-000000000000', N'Service')
INSERT [dbo].[Application] ([ID], [Name]) VALUES (N'b9343013-600c-4248-b606-1fd1cd4fced9', N'WP7')
INSERT [dbo].[Application] ([ID], [Name]) VALUES (N'c00348ab-608e-40b2-87c9-29496310ecf0', N'Android')
INSERT [dbo].[Application] ([ID], [Name]) VALUES (N'74c560d4-690d-4d87-9993-841267df32ba', N'iPhone/iPad')
/****** Object:  Table [dbo].[Device]    Script Date: 01/20/2012 17:17:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Device](
	[ID] [uniqueidentifier] NOT NULL,
	[MemberID] [uniqueidentifier] NOT NULL,
	[ApplicationID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](500) NULL,
 CONSTRAINT [PK_MemberDevice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF)
)
GO
INSERT [dbo].[Device] ([ID], [MemberID], [ApplicationID], [Name]) VALUES (N'cdc72644-77a2-497d-ad72-12ce9ad897bf', N'6005c30a-c5d0-410d-a82c-65431c9638d1', N'00000000-0000-0000-0000-000000000000', N'Service')
INSERT [dbo].[Device] ([ID], [MemberID], [ApplicationID], [Name]) VALUES (N'329df94e-9b9a-45ea-92da-1c9e6085af8c', N'6005c30a-c5d0-410d-a82c-65431c9638d1', N'74c560d4-690d-4d87-9993-841267df32ba', N'Shaun''s iPad 2')
INSERT [dbo].[Device] ([ID], [MemberID], [ApplicationID], [Name]) VALUES (N'665328ae-b690-46ae-acd2-b082fc72ff88', N'6005c30a-c5d0-410d-a82c-65431c9638d1', N'b9343013-600c-4248-b606-1fd1cd4fced9', N'Shaun''s Windows Phone 7')
INSERT [dbo].[Device] ([ID], [MemberID], [ApplicationID], [Name]) VALUES (N'559c148c-906b-41d2-9d7a-c0461f23d23e', N'6005c30a-c5d0-410d-a82c-65431c9638d1', N'c00348ab-608e-40b2-87c9-29496310ecf0', N'Shaun''s HTC G4')
/****** Object:  Table [dbo].[DiaryItem]    Script Date: 01/20/2012 17:17:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DiaryItem](
	[ID] [uniqueidentifier] NOT NULL,
	[Content] [nvarchar](4000) NOT NULL,
	[UpdatedVersion] [bigint] NOT NULL,
	[UpdatedDeviceID] [uniqueidentifier] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
	[UpdatedOn] [datetime] NOT NULL,
 CONSTRAINT [PK_DiaryItem] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF)
)
GO
/****** Object:  Default [DF_Member_ID]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[Member] ADD  CONSTRAINT [DF_Member_ID]  DEFAULT (newid()) FOR [ID]
GO
/****** Object:  Default [DF_Application_ID]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[Application] ADD  CONSTRAINT [DF_Application_ID]  DEFAULT (newid()) FOR [ID]
GO
/****** Object:  Default [DF_MemberDevice_ID]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[Device] ADD  CONSTRAINT [DF_MemberDevice_ID]  DEFAULT (newid()) FOR [ID]
GO
/****** Object:  Default [DF_DiaryItem_ID]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[DiaryItem] ADD  CONSTRAINT [DF_DiaryItem_ID]  DEFAULT (newid()) FOR [ID]
GO
/****** Object:  Default [DF_DiaryItem_IsDeleted]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[DiaryItem] ADD  CONSTRAINT [DF_DiaryItem_IsDeleted]  DEFAULT ((1)) FOR [IsDeleted]
GO
/****** Object:  ForeignKey [FK_Device_Application]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[Device]  WITH CHECK ADD  CONSTRAINT [FK_Device_Application] FOREIGN KEY([ApplicationID])
REFERENCES [dbo].[Application] ([ID])
GO
ALTER TABLE [dbo].[Device] CHECK CONSTRAINT [FK_Device_Application]
GO
/****** Object:  ForeignKey [FK_Device_Member]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[Device]  WITH CHECK ADD  CONSTRAINT [FK_Device_Member] FOREIGN KEY([MemberID])
REFERENCES [dbo].[Member] ([ID])
GO
ALTER TABLE [dbo].[Device] CHECK CONSTRAINT [FK_Device_Member]
GO
/****** Object:  ForeignKey [FK_DiaryItem_UpdatedDevice]    Script Date: 01/20/2012 17:17:48 ******/
ALTER TABLE [dbo].[DiaryItem]  WITH CHECK ADD  CONSTRAINT [FK_DiaryItem_UpdatedDevice] FOREIGN KEY([UpdatedDeviceID])
REFERENCES [dbo].[Device] ([ID])
GO
ALTER TABLE [dbo].[DiaryItem] CHECK CONSTRAINT [FK_DiaryItem_UpdatedDevice]
GO
